package beans.annotation.tape;

/**
 * 磁带运转机械装置
 * 
 * @author yangjuntao@p-an.com 2013年11月19日
 */
public class TapeDeckHandler
{
	@State
	public static final String EMPTY = "Empty";
	@State
	public static final String LOADED = "Loaded";
	@State
	public static final String PLAYING = "Playing";
	@State
	public static final String PAUSED = "Paused";

	/**
	 * 当录音机处于EMPTY空状态时(in)，磁带装载事件启动后会触发loadTape方法(on)，并且录音机状态将会变换到Loaded状态(next)
	 * 
	 * @param nameOfTape
	 */
	@Transition(on = "load", in = EMPTY, next = LOADED)
	public void loadTape(final String nameOfTape)
	{
		System.out.println("Tape'" + nameOfTape + "' loaded");
	}

	@Transitions({ @Transition(on = "play", in = LOADED, next = PLAYING), @Transition(on = "play", in = PAUSED, next = PLAYING) })
	public void playTape()
	{
		System.out.println("Playing tape");
	}

	@Transition(on = "pause", in = PLAYING, next = PAUSED)
	public void pauseTape()
	{
		System.out.println("Tape paused");
	}

	@Transition(on = "stop", in = PLAYING, next = LOADED)
	public void stopTape()
	{
		System.out.println("Tape stopped");
	}

	@Transition(on = "eject", in = LOADED, next = EMPTY)
	public void ejectTape()
	{
		System.out.println("Tape ejected");
	}
}
